package com.shj.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.shj.model.SysTeam;
import com.shj.service.SysTeamService;
import com.shj.web.util.MyIdUtil;
import com.shj.web.util.MyTimeUtil;
import com.shj.web.util.ResultUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * (SysTeam)表控制层
 *
 * @author makejava
 * @since 2020-03-12 12:49:36
 */
@Controller
@RequestMapping("/team")
public class SysTeamController {
    /**
     * 服务对象
     */
    @Resource
    private SysTeamService sysTeamService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    @ResponseBody
    public SysTeam selectOne(Integer id) {
        return this.sysTeamService.queryById(id);
    }

    @PostMapping("/add")
    @ResponseBody
    public void addTeam(@RequestBody SysTeam sysTeam){
        String teamId = MyIdUtil.getForTimeId();
        String signTime = MyTimeUtil.getForString();

        sysTeam.setTeamId(teamId);
        sysTeam.setSignTime(signTime);
        System.out.println(JSONObject.toJSONString(sysTeam));
    }
}